package com.fenghongzhang.day006;

import android.os.Bundle;
import android.view.View;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {
    private Button btn;
    private ImageView img;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        btn = (Button) findViewById(R.id.btn);
        img = (ImageView) findViewById(R.id.img);

    }

    public void btn(View view) {
//        Animation animation = AnimationUtils.loadAnimation(this, R.anim.alpha);

//        Animation rotate = AnimationUtils.loadAnimation(this, R.anim.rotate);

//        Animation animation = AnimationUtils.loadAnimation(this, R.anim.scale);

//        Animation translate = AnimationUtils.loadAnimation(this, R.anim.translate);


        //组合动画
//        AnimationSet animationSet = new AnimationSet(true);
//        animationSet.addAnimation(rotate);
//        animationSet.addAnimation(translate);
//        animationSet.setFillAfter(true);

//        img.startAnimation(translate);

        //java代码的方式
//        AlphaAnimation alphaAnimation = new AlphaAnimation(1,0);
//        alphaAnimation.setDuration(2000);
//        alphaAnimation.setFillAfter(true);

        //java代码移动动画
        TranslateAnimation translateAnimation = new TranslateAnimation(0, 200, 0, 200);
        translateAnimation.setDuration(2000);
        translateAnimation.setFillAfter(true);
        img.startAnimation(translateAnimation);

//        new AlphaAnimation()
//        new ScaleAnimation()
//        new RotateAnimation()

    }
}
